Thermal Waves

January 11, 2022

In this tutorial we will interpolate between points provided in a thermistor calibration file and then use the interpolated data to convert a set of resistance measurements in ohms to temperature in celsius.

The first step is to import the calibration data and the experimentally measured resistance readings.

Here's the calibration data

To do the interpolation, we will use the Python module 'SciPy' and the function 'interp1d()'.

To use interp1, you first must supply the x calibration data (Rcal) and the y calibration data (Tcal).

'interp1d()' creates a function, which we called 'f_lin_interp' that we can now evaluate at any x (in our case resistance) value that is within the interpolation range. The interpolation range will be the values of resistance that fall between the min and max values in Rcal.

We can use this function to plot a continuouse calibration curve.

Show the calibration data...

The interpolation that we just did simply connects the space between the points with straight lines. If we want to have the points joined by a smooth curve we can add the option 'kind = 'cubic'' to 'interp1d()'. This time, I will also add the option 'fill_value = 'extrapolate'' which will allow use to estimate values of T outside of the interpolation range.

Show the calibration data...

We'll show these curve together a second time while zoomed into a narrow range of R values. This will highlight the difference between the linear and cuboc interpolations.

Show the calibration data...

Here are the measured resistances from a PHYS 232 thermal waves experiment.

The first column of data in the file is time in seconds.

Here's a plot of the data after using cubic interpolation function to convert the resistance measurements to temperatures.

In the thermal waves experiment, we're not interested in the average temperature of the copper rod. We're really only interested in the temperature oscillations. In the plot above we'd like to subtract off the average temperature. However, the average temperature drifts with time. Therefore, we will define a window of size N, determine the average temperature of within that window a subtract that value from the measured temperature at the centre of the window. That window of N points will be used across the entire data set. In the end, we will have data set centred on zero with N/2 fewer points at the beginning and end of the array.

We will import the `pandas' module to help use with our moving average.

First, convert the measured resistances using the interpolation function defined above.

Also, define the size of the average window. I tried to make the averaging window correspond to approximately one period of the observed oscillations.

Here are some commands from the pandas modul to create the windows of size N and then find the mean values in each window.

Now put the calculated averages into a list that can be used to correct the temperature data.

Finally...

Let's export this corrected tempperature data for further processing. For example, in the thermal waves analysis we will want to take the Fourier transform of this data and extract the amplitude of the fundamental Fourier component.